import { ResPage, Inventory } from "@/api/interface/index";
import { PORT1 } from "@/api/config/servicePort";
import http from "@/api";
import qs from "qs";

/**
 * @name 库存管理模块
 */

// 获取客户列表
export const getCustomList = (params: {}) => {
  return http.post<ResPage<Inventory.ResCustomList>>(PORT1 + `/CoreCmsCustom/GetPageList`, qs.stringify(params));
};

// 新建客户信息
export const createCustom = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsCustom/DoCreate`, params);
};

// 编辑客户信息
export const editCustom = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsCustom/DoEdit`, params);
};

// 删除客户信息
export const deleteCustom = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsCustom/DoDelete`, params);
};

// 获取客户信息
export const getCustom = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsCustom/GetEdit`, params);
};

// 获取商品分类列表
export const getWaresCategoryList = (params: {}) => {
  return http.post<ResPage<Inventory.ResWaresCategoryList>>(PORT1 + `/CoreCmsGoodsCategory/GetPageList`, qs.stringify(params));
};

// 创建商品分类
export const createWaresCategory = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsGoodsCategory/DoCreate`, params);
};

// 编辑商品分类
export const editWaresCategory = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsGoodsCategory/DoEdit`, params);
};

// 删除商品分类
export const deleteWaresCategory = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsGoodsCategory/DoDelete`, params);
};

// 获取商品品牌列表
export const getWaresBrandList = (params: {}) => {
  return http.post<ResPage<Inventory.ResWaresCategoryList>>(PORT1 + `/CoreCmsBrand/GetPageList`, qs.stringify(params));
};
// 创建商品品牌
export const createWaresBrand = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsBrand/DoCreate`, params);
};

// 编辑商品品牌
export const editWaresBrand = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsBrand/DoEdit`, params);
};

// 删除商品品牌
export const deleteWaresBrand = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsBrand/DoDelete`, params);
};

// 获取商品列表
export const getWaresList = (params: {}) => {
  return http.post<ResPage<Inventory.ResWaresList>>(PORT1 + `/CoreCmsGoods/GetGoodProcuctPageList`, qs.stringify(params));
};

// 模糊查询商品列表
export const getIndistinctWaresList = (params: {}) => {
  return http.post<ResPage<Inventory.ResWaresList>>(PORT1 + `/CoreCmsGoods/GetGoodsList`, qs.stringify(params));
};

// 创建商品
export const createWares = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsGoods/DoCreate`, params);
};

// 编辑商品
export const editWares = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsGoods/DoEdit`, params);
};

// 删除商品
export const deleteWares = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsGoods/DoDelete`, params);
};

// 获取商品资料
export const getEditWares = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsGoods/GetEdit`, params);
};

// 获取供应商列表
export const getSupplierList = (params?: {}) => {
  return http.post<ResPage<Inventory.ResSupplierList>>(PORT1 + `/CoreCmsSupplier/GetPageList`, qs.stringify(params));
};
// 新增供应商
export const createSupplier = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsSupplier/DoCreate`, params);
};

// 编辑供应商
export const editSupplier = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsSupplier/DoEdit`, params);
};

// 删除供应商
export const deleteSupplier = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsSupplier/DoDelete`, params);
};

// 获取供应商区域列表
export const getSupplierRegionList = (params: {}) => {
  return http.post<ResPage<Inventory.ResSupplierRegionList>>(PORT1 + `/CoreCmsSupplierRegion/GetPageList`, qs.stringify(params));
};

// 新增供应商区域
export const createSupplierRegion = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsSupplierRegion/DoCreate`, params);
};

// 编辑供应商区域
export const editSupplierRegion = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsSupplierRegion/DoEdit`, params);
};

// 删除供应商区域
export const deleteSupplierRegion = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsSupplierRegion/DoDelete`, params);
};

// 获取采购单列表
export const getPurchaseList = (params: {}) => {
  return http.post<ResPage<Inventory.ResPurchaseList>>(PORT1 + `/CoreCmsPurchase/GetPageList`, qs.stringify(params));
};

// 新增采购单
export const createPurchase = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsPurchase/DoCreate`, params);
};

// 编辑采购单
export const editPurchase = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsPurchase/DoEdit`, params);
};
// 删除采购单
export const deletePurchase = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsPurchase/DoDelete`, params);
};
// 审核采购单
export const checkPurchase = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsPurchase/DoCheck`, params);
};
// 反审核采购单
export const cancelCheckPurchase = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsPurchase/CancelCheck`, params);
};

// 获取采购单信息
export const getPurchase = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsPurchase/GetEdit`, params);
};

// 获取入库单、退货单列表
export const getStockinList = (params: {}) => {
  return http.post<ResPage<Inventory.ResPurchaseList>>(PORT1 + `/CoreCmsStockin/GetPageList`, qs.stringify(params));
};

// 新增入库单，退货单
export const createStockin = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsStockin/DoCreate`, params);
};

// 编辑入库单，退货单
export const editStockin = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsStockin/DoEdit`, params);
};

// 关闭入库单，退货单
export const closeStockin = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsStockin/DoClose`, params);
};

// 确认收货，退货单
export const confirmStockin = (params: {}) => {
  return http.post(PORT1 + `/corecmsstockin/Confirm`, params);
};

// 删除入库，退货单
export const deleteStockin = (params: {}) => {
  return http.post(PORT1 + `/corecmsstockin/DoDelete`, params);
};

// 撤销收货，退货单
export const cancelStockin = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsStockin/DoCancel`, params);
};
// 根据id获取撤销收货，退货单
export const getStockin = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsStockin/GetEdit`, params);
};

// 获出库单列表
export const getStockOutList = (params: {}) => {
  return http.post<ResPage<Inventory.ResStockOutList>>(PORT1 + `/CoreCmsStockOut/GetPageList`, qs.stringify(params));
};

// 新增出库单
export const createStockOut = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsStockOut/DoCreate`, params);
};

// 删除出库单
export const deleteStockOut = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsStockOut/DoDelete`, params);
};

// 获取出库单资料
export const getStockOut = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsStockOut/GetEdit`, params);
};

// 编辑出库单资料
export const editStockOut = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsStockOut/DoEdit`, params);
};

// 审核出库单
export const checkStockOut = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsStockOut/DoCheck`, params);
};
// 反审核出库单
export const unCheckStockOut = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsStockOut/DoCancel`, params);
};

// 导出 出库单
export const exportStockOut = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsStockOut/DoExport`, params);
};

// 获取库存列表
export const getGoodTotalList = (params: {}) => {
  return http.post<ResPage<Inventory.ResGoodTotalList>>(PORT1 + `/CoreCmsGoodTotal/GetPageList`, qs.stringify(params));
};

// 获取仓库列表
export const getStorehouseList = (params: {}) => {
  return http.post<ResPage<Inventory.ResStorehouseList>>(PORT1 + `/CoreCmsStorehouse/GetPageList`, qs.stringify(params));
};

// 创建仓库
export const createStorehouse = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsStorehouse/DoCreate`, params);
};

// 编辑仓库资料
export const editStorehouse = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsStorehouse/DoEdit`, params);
};

// 删除仓库
export const deleteStorehouse = (params: {}) => {
  return http.post(PORT1 + `/CoreCmsStorehouse/DoDelete`, params);
};

/* 
qs.stringify将对象格式转为一个字符串
ResPage 分页响应参数类型
Inventory 里面定义的是响应回来的数据类型
*/
// 获取盘点计划列表
export const getStockPlanList = (params: {}) => {
  return http.post<ResPage<Inventory.ResStockPlanList>>(PORT1 + `/corecmsinventoryplan/GetPageList`, qs.stringify(params));
};

// 新增盘点计划
export const createStockPlan = (params: {}) => {
  return http.post(PORT1 + `/corecmsinventoryplan/DoCreate`, params);
};

// 修改盘点计划数据
export const editStockPlan = (params: {}) => {
  return http.post(PORT1 + `/corecmsinventoryplan/DoEdit`, params);
};
// 获取盘点计划数据
export const getStockPlanEdit = (params: {}) => {
  return http.post(PORT1 + `/corecmsinventoryplan/GetEdit`, params);
};

// 删除盘点计划
export const deleteStockPlan = (params: {}) => {
  return http.post(PORT1 + `/corecmsinventoryplan/DoDelete`, params);
};

// 审核盘点计划
export const checkStockPlan = (params: {}) => {
  return http.post(PORT1 + `/corecmsinventoryplan/DoCheck`, params);
};

// 获取盘点计划明细
export const getDetailStockPlan = (params: {}) => {
  return http.post(PORT1 + `/corecmsinventorydetail/GetPageList`, params);
};

// 获取盘点计划详情分页
export const getDetailPlanPageList = (params: {}) => {
  return http.post<ResPage<any>>(PORT1 + `/corecmsinventoryplan/GetDetailPageList`, qs.stringify(params));
};

// 修改盘点计划明细
export const editDetailStockPlan = (params: {}) => {
  return http.post(PORT1 + `/corecmsinventoryplandetail/DoBatchEdit`, params);
};

// 获取库存商品
export const getInventoryGoodsList = (params: {}) => {
  return http.post<ResPage<Inventory.ResStockPlanList>>(PORT1 + `/CoreCmsGoods/GetInventorProductPageList`, qs.stringify(params));
};

// --查询盘点
export const getStockRealSheetList = (params: {}) => {
  return http.post<ResPage<Inventory.ResStockRealSheetList>>(PORT1 + `/corecmsinventory/GetPageList`, qs.stringify(params));
};

//新增盘点
export const createStockRealSheet = (params: {}) => {
  return http.post(PORT1 + `/corecmsinventory/DoCreate`, params);
};

//删除盘点
export const deleteStockRealSheet = (params: {}) => {
  return http.post(PORT1 + `/corecmsinventory/DoDelete`, params);
};

//修改盘点
export const editStockRealSheet = (params: {}) => {
  return http.post(PORT1 + `/corecmsinventory/DoEdit`, params);
};

//获取盘点详情
export const getStockRealSheetDetail = (params: {}) => {
  return http.post(PORT1 + `/corecmsinventory/GetEdit`, params);
};

// 审核盘点
export const checkStockRealSheet = (params: {}) => {
  return http.post(PORT1 + `/corecmsinventory/DoCheck`, params);
};

// 获取库存流水列表
export const getStockStatementList = (params: {}) => {
  return http.post<ResPage<Inventory.ResStockStatementList>>(PORT1 + `/corecmsinventoryflow/GetPageList`, qs.stringify(params));
};

export const getStockCheckoutAPI = (params: {}) => {
  return http.post<ResPage<Inventory.StockCheckoutList>>(PORT1 + "/corecmsstockin/GetStockInOrOutPage", qs.stringify(params));
};
